	var ii = 0;
	var j = 1;
	function insert(obj){
		var str = document.getElementById(obj).value.split('\\');
		str = str[str.length-1];
		var type = str.substr(str.indexOf('.')+1);
		if(type.toLowerCase() != 'jpg' && type.toLowerCase() != 'gif' && type.toLowerCase() != 'jpeg' && type.toLowerCase() != 'png'){
			alert("只支持gif, jpg, jpeg, png 类型!");
			$("#tr"+document.getElementById(obj).id.substr(4)).remove();
			var content = "<tr id='tr"+i+"'><td id='td"+ii+"' height=20><input type='file' id='file"+ii+"' name='attachments["+j+"]' size='40' onchange='insert(this.id);'/><input type='hidden' name='localid["+(j)+"]' value='"+ii+"' /></td></tr>";
			$("#image").append(content);
			return false;
		}
		$('#'+obj).hide();
		$("#"+$('#'+obj).parent().attr('id')).append("<a href='javascript:void(0);' id='a"+ii+"' onclick='remove(this.id);'>[删除]</a>　<a href='javascript:void(0)' id='aa"+ii+"' onmouseover='show(this);' onmouseout='hide(this);'>"+'['+(ii+1)+']' +'  '+str+"</a>"+"　<a href='javascript:void(0);' onclick='insertEditor("+ii+")'>[插入]</a>");
		ii++;
		var content = "<tr id='tr"+ii+"'><td id='td"+ii+"' height=20><input type='file' id='file"+ii+"' name='attachments["+(j++)+"]' size='40' onchange='insert(this.id);'/><input type='hidden' name='localid[]' value='"+ii+"' /></td></tr>";
			$("#image").append(content);
	}
	
	function remove(id){
		$('#tr'+id.substr(1)).remove();
	}
	
	function show(obj){
		var src = $('#'+$('#'+obj.id).parent().attr('id')).find('input').val();
		var offset = fetchOffset(obj);
		$('body').append("<div id='div"+obj.id.substr(2)+"' style='position:absolute;top:"+offset.top+";left:"+(offset.left+100)+"'><img src='"+src+"' border=3 style='border-color:#CCCCCC' /></div>");
	}
	
	function showimg(id , src)
	{
		var obj = document.getElementById(id);
		var offset = fetchOffset(obj);
		$('body').append("<div id='divedit"+id+"' style='position:absolute;top:"+offset.top+";left:"+(offset.left+100)+"'><img src='"+src+"' border=3 style='border-color:#CCCCCC' width='200' height='180'/></div>");
	}
	
	function hideimg(id)
	{
		$('#divedit'+id).remove();
	}
	
	function insertEditor(id){
		var src = $('#'+$('#aa'+id).parent().attr('id')).find('input').val();
		var imgObj = new Image();
		imgObj.src = src;
		var img = "<img localid='"+id+"' src='"+src+"' />";
		Insertpic1(img);
	}
	
	function hide(obj){
		var id = obj.id.substr(2);
		$('#div'+id).remove();
	}
	
	function fetchOffset(obj) {
		var left_offset = obj.offsetLeft;
		var top_offset = obj.offsetTop;
		while((obj = obj.offsetParent) != null) {
			left_offset += obj.offsetLeft;
			top_offset += obj.offsetTop;
		}
		return { 'left' : left_offset, 'top' : top_offset };
	}

	function Insertpic1(str)
	{
		editor.focus();
		editor.pasteHTML(str);
	}